# $Id$
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Yejun Yang <yejunx AT gmail DOT com>
# Contributor: Michal Krenek <mikos@sg1.cz>

pkgname=libsrtp
pkgver=2.2.0
pkgrel=1
epoch=1
pkgdesc="Library for SRTP (Secure Realtime Transport Protocol)"
url="https://github.com/cisco/libsrtp"
arch=(x86_64)
license=(BSD)
depends=(openssl)
makedepends=(git)
checkdepends=(libpcap procps-ng)
options=(staticlibs)
_commit=94ac00d5ac6409e3f6409e4a5edfcdbdaa7fdabe  # tags/v2.2.0
source=("git+https://github.com/cisco/libsrtp#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgname

  # Fixup pkgver: There are tags like v1.5.4 but also "moving" tags like v1 and v1.5
  git tag | grep -Pv '^v\d+.\d+.\d+$' | xargs git tag -d

  autoreconf -fvi
}

build() {
  cd $pkgname
  ./configure --prefix=/usr --enable-openssl
  make all
  make shared_library  # Keep separate to link test apps against static lib
}

check() {
  cd $pkgname
  make runtest
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 LICENSE
}
